package com.planetarium;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;

import javax.swing.JComponent;

import com.planetarium.objects.PlanetarySystem;

public class JSolarSystem extends JComponent {
	
	private static final long serialVersionUID = 9192764410227019645L;
	private PlanetarySystem solarSystem;

	public JSolarSystem() {
		super();

		setMinimumSize(new Dimension(0, 0));
		setPreferredSize(new Dimension(800, 600));
	}
	
	/*
	 * 
	 * Paints the solar-system.
	 * 
	 */
	
	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		
		Graphics2D g2 = (Graphics2D) g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		
		Color defaultColor = g2.getColor();
		g2.setColor(new Color(0, 0, 0));
		g2.fillRect(0, 0, getWidth(), getHeight());
		g2.setColor(defaultColor);
		
		if (solarSystem != null)
			solarSystem.render(g2, new Rectangle(0, 0, getWidth(), getHeight()));
	}
	
	/*
	 * 
	 * Sets the solar-system to be rendered by this
	 * renderer.
	 * 
	 */
	
	public void setSolarSystem(PlanetarySystem dummySystem) {
		this.solarSystem = dummySystem;	
	}
	
}
